---
title: XDesignXDocument
summary: API reference for XDesignXDocument.
status: draft
owner: SAIF Documentation
last_reviewed: 2026-08-21
library: SAIF.Services.Printing
reference_type: embedded
---

# XDesignXDocument

`XDesignXDocument` is the root-document counterpart to `XDesignXElement`: it wraps a `SAIFXDocument` (from
`SAIF.Framework.Common`) so a report's data tree can be serialized to the xPression XML dialect via
`ToXpression()`. `ReportBase.Render` calls `ToXpression()` on the document produced by a subclass's `Create`
override before handing the resulting string to `clsPrint.previewDocument`.

## Purpose
- Provide the document-level entry point for xPression serialization, delegating to the root element's
  `ToXpression` when it is an `XDesignXElement`
- Guard against malformed documents by returning an empty string when there is no root, or the root is not an
  xPression element ([BR-PRT-019](../../business-rules.md#br-prt-019-empty-serialization-for-malformed-documents))

## Context
- Namespace: `SAIF.Services.Printing.Reporting`
- Assembly/package: `SAIF.Services.Printing` (embedded library, project reference)
- Base class: `SAIFXDocument` (`SAIF.Framework.Common` package)

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| `New()` | `Public Sub New()` | Constructs an empty document, mirroring the base `SAIFXDocument()` constructor |
| `New(content)` | `Public Sub New(ParamArray content As Object())` | Constructs a document from the supplied content, mirroring the base constructor |
| `New(other)` | `Public Sub New(other As XDocument)` | Constructs a document by copying an existing `XDocument`, mirroring the base constructor |
| `New(declaration, content)` | `Public Sub New(declaration As XDeclaration, ParamArray content As Object())` | Constructs a document with an explicit XML declaration, mirroring the base constructor |
| `ToXpression` | `Public Function ToXpression() As String` | Returns the root element's `ToXpression()` rendering when the root is an `XDesignXElement`; otherwise returns `""` ([BR-PRT-019](../../business-rules.md#br-prt-019-empty-serialization-for-malformed-documents)) |

## Behavioral notes
- `ToXpression()` performs no recursive walk itself — all element-level rendering (key propagation, escaping,
  self-closing empty elements) is implemented on `XDesignXElement`; this type only decides whether the root is
  eligible to be rendered at all.

## Constraints and usage notes
- Building a document whose root is a plain `XElement` (not lifted via `Extensions.ToSAIFXElement`) will cause
  `ToXpression()` to return an empty string rather than throwing.*

> **Note:** Statements marked with * were inferred from code structure, naming conventions, or
> contextual evidence where direct confirmation was not available in source artifacts.

## Sources
- SAIF.Services.Printing/Reporting/XDesignXDocument.vb
